package com.cndcare.msc.netty.service.impl;

import com.cndcare.msc.cloud.base.common.LayuiPageInfo;
import com.cndcare.msc.netty.bean.BindAlarmBean;
import com.cndcare.msc.netty.dao.jpa.BindAlarmBeanJpa;
import com.cndcare.msc.netty.dao.mapper.AlarmMapper;
import com.cndcare.msc.netty.service.AlarmService;
import com.cndcare.msc.netty.vo.SearchVo;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("alarmService")
public class AlarmServiceImpl implements AlarmService {

    @Autowired
    private AlarmMapper alarmMapper;
    @Autowired
    private BindAlarmBeanJpa bindAlarmBeanJpa;

    @Override
    public PageInfo<BindAlarmBean> listBindAlarmByParams(Integer pn, Integer pageSize, SearchVo searchVo) {
        PageHelper.startPage(pn, pageSize);

        List<BindAlarmBean> bindAlarmBeanList =
                alarmMapper.listBindAlarmByParams(searchVo);
        return new LayuiPageInfo<>(bindAlarmBeanList);
    }

    @Override
    public boolean bindConfirm(Long count) {
        Long size = bindAlarmBeanJpa.count();

        return size > count;
    }
}
